#ifndef _SMP_PROGBAR_H
#define _SMP_PROGBAR_H

#include "sgl_funcs.h"
#include "sgl_window.h"


enum {
	SMP_PROGBAR_SETRANGE,
	SMP_PROGBAR_SETVALUE
	//,SMP_PROGBAR_WNDPROC
};

#ifndef SDK_NO_PLUGIN
#define SMP_PROGBAR_WNDPROC MPS_CODE_SMP_PROGBAR_PROC
#else
#define SMP_PROGBAR_WNDPROC SMP_ProgBar_WndProc
#endif

/**
  \defgroup smp_progbar Simple Progress Bar

  To work with the simple progress bar:
  - Create the progress bar
  - Set the progress bar range
  - Add to the parent window
  - Response to the notify message

  \code
  	//create the scrollbar
  	hPorgBar = SGL_CreateWindow(SMP_ProgBar_WndProc, ...);
  	SMP_ProgBar_SetRange(hPorgBar, 1, 30); //the default range is [0 - 99] when this function not called
  	SGL_AddChildWindow(hWnd, hPorgBar);

  	//response to the notify message
	case WM_COMMAND:
		WID id = LOWORD(wParam);
		WORD code = HIWORD(wParam);

		if(id == "the progbar id" && code == SMP_PROGBARN_VALUECHANGED)
		{
			int value = (int)lParam; //current progress bar value
		}	
  \endcode
  
  @ingroup controls
  @{
*/

	/**
	 * \name Window Notify Messages
	 * @{
	 */

/**
 * \brief Progress Bar window value changed notify message.
 *
 * \code
 *	case WM_COMMAND:
 *		WID id = LOWORD(wParam);
 *		WORD code = HIWORD(wParam);
 *
		if(id == "the progbar id" && code == SMP_PROGBARN_VALUECHANGED)
		{
			int value = (int)lParam; //current progbar value
		}	
 * \endcode
 *
 * \param value the  current value
 */
#define SMP_PROGBARN_VALUECHANGED		0x0001

	/** @} */

	/**
	 * \name Window Member Functions
	 * @{
	 */

#if defined(INCLUDE_IN_PLUG_SGL_SRC) || defined(SDK_NO_PLUGIN)
/**
 * \brief Set the progress bar range. After the creation of the window the default range is [0-99].
 *
 * \param hWnd the progress bar window handle
 * \param min the min value of the progress bar
 * \param max the max value of the progress bar
 */
int32 SMP_ProgBar_SetRange(HWND hWnd, Sint32 min, Sint32 max);

/**
 * \brief Set the progress bar value
 *
 * \param hWnd the progress bar handle
 * \param value the new value
 * \param redraw if redraw the progress bar
 * \param notify send the notify message if value changed
 */
int32 SMP_ProgBar_SetValue(HWND hWnd, Sint32 value, BOOL redraw, BOOL notify);

	/** @} */

	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief Progress bar procedure
 *
 * \param hWnd the window handle
 * \param Msg the window message
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */
LRESULT SMP_ProgBar_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
#else
/**
 * \brief Set the progress bar range. After the creation of the window the default range is [0-99].
 *
 * \param hWnd the progress bar window handle
 * \param min the min value of the progress bar
 * \param max the max value of the progress bar
 */
#define SMP_ProgBar_SetRange(hWnd, min, max) \
	mrc_extSendAppEventEx(MPS_CODE_SMP_PROGBAR, SMP_PROGBAR_SETRANGE, (int32)hWnd, (int32)min, (int32)max, (int32)0, (int32)0)

/**
 * \brief Set the progress bar value
 *
 * \param hWnd the progress bar handle
 * \param value the new value
 * \param redraw if redraw the progress bar
 * \param notify send the notify message if value changed
 */
#define SMP_ProgBar_SetValue(hWnd, value, redraw, notify) \
	mrc_extSendAppEventEx(MPS_CODE_SMP_PROGBAR, SMP_PROGBAR_SETVALUE, (int32)hWnd, (int32)value, (int32)redraw, (int32)notify, (int32)0)

	/** @} */

	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief Progress bar procedure
 *
 * \param hWnd the window handle
 * \param Msg the window message
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */
#define SMP_ProgBar_WndProc(hWnd, Msg, wParam, lParam) \
	(LRESULT)mrc_extSendAppEventEx(MPS_CODE_SMP_PROGBAR_PROC, (int32)hWnd, (int32)Msg, (int32)wParam, (int32)lParam, (int32)0, (int32)0)
#endif
	
	/** @} */
	
/** @} end of smp_progbar */

#endif
